home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13056 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
  2. From: grantp@usa.pipeline.com(Pete Grant)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Drawing from any procedure
  5. Date: 23 Mar 1996 03:50:31 GMT
  6. Organization: Pipeline USA
  7. Message-ID: <4ivse7$3p1@news1.h1.usa.pipeline.com>
  8. References: <4iuni1$oep@lily.csv.warwick.ac.uk>
  9. NNTP-Posting-Host: 38.8.61.11
  10. X-PipeUser: grantp
  11. X-PipeHub: usa.pipeline.com
  12. X-PipeGCOS: (Pete Grant)
  13. X-Newsreader: Pipeline v3.5.0
  14.  
  15. On Mar 22, 1996 17:21:05 in article <Drawing from any procedure>,
  16. 'esuvx@csv.warwick.ac.uk (Adge)' wrote: 
  17.  
  18.  
  19. >I am programming in ms Visual C++ v.4.0 under Win95, and am trying to  
  20. >persuade it to allow me to draw graphics to a window from a procedure
  21. other 
  22. >than OnPaint or OnDraw. 
  23. >I have tried using CPaintDC(this); , but this gives an access violation. 
  24. >It used to be possible under Borland Pascal for win but I can't work out 
  25. >how to do it under visc++ 
  26. >Can anyone help ? 
  27. This really belongs to comp.os.ms-windows.programmer.tools.mfc, but  
  28. since we're here... 
  29.  
  30. CPaintDC can be used only in functions called in response to 
  31. WM_PAINT messages; e.g., OnPaint.  If you wish to to GDI output at 
  32. any other time, you need to use CDC instead.  Alternately, you 
  33. can switch to raw API: 
  34.  
  35.  HDC hDC = ::GetDC(m_hWnd); 
  36.   ... do your drawing,,, 
  37.   ::ReleaseDC(m_hWnd, hDC); 
  38.  
  39. -- 
  40.  
  41. Pete Grant 
  42. Kalevi, Inc. 
  43. Sofware Engineering
  44.